/*
 * > /*
>  * INSANE - Interactive Structural Analysis Environment
>  *
>  * Copyright (C) 2003-2004
>  * Universidade Federal de Minas Gerais
>  * Escola de Engenharia
>  * Departamento de Engenharia de Estruturas
>  *
>  * Author's email :     insane@dees.ufmg.br
>  * Author's Website :   http://www.dees.ufmg.br/insane
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
> 1307, USA.
 *
 */

package br.ufmg.dees.insane.model.postp;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

import br.ufmg.dees.insane.util.IPoint3d;

/**
 * The class represents a point of the postpModel.
 * This point has a undefined number of Key/values to be set in a HashMap. 
 * @author Samuel Silva Penna
 * @since 13/06/2006
 */
public class PointModel implements Serializable{

	/**   */
	private static final long serialVersionUID = 1L;
	/** The label of this PointModel */
	private String label;
	/** The coord x of this PointModel */
	private double x;
	/** The coord y of this PointModel */
	private double y;
	/** The coord z of this PointModel */
	private double z;
	/** The coords of this PointModel */
	private IPoint3d coord;
	/** The HashMap that Contains the values of this PointModel */
	private HashMap<String, Object> values;
    /** The HashMap that Contains the values of this PointModel */
    private HashMap<String, Object> contMap;
	
	private ArrayList<String> keys;
	
	/** 
	 * The Default constructor  
	 */
	public PointModel() {
		this.values = new HashMap<String, Object>();
        this.contMap = new HashMap<String, Object>();
		this.keys = new ArrayList<String>();
	}
	
	/** 
	 * The constructor contructs a pointModel and initialize
	 * the coordinates of this point from the parameter points. 
	 * @param point The coords of this PointModel.
	 */
	public PointModel(IPoint3d point) {
		this.x = point.x;
		this.y = point.y;
		this.z = point.z;
		this.coord = point;
		this.values = new HashMap<String, Object>();
        this.contMap = new HashMap<String, Object>();
		this.keys = new ArrayList<String>();
	}
	
	/** 
     * The constructor contructs a pointModel and initialize
	 * the coordinates and the HashMap of this point from the 
	 * parameters points, Keys and values respectively.
	 * @param point The coordinates of this poinModel 
	 * @param Key The Keys of the values to be set
	 * @param value All values of this point 
	 */
	public PointModel(IPoint3d point,String[] Keys, Object[] values) {
		this.x = point.x;
		this.y = point.y;
		this.z = point.z;
		this.coord = point;
		this.values = new HashMap<String, Object>(Keys.length);
		this.keys = new ArrayList<String>();
		for(int i=0;i<Keys.length;i++){
			this.values.put(Keys[i], values[i]);
			this.keys.add(Keys[i]);
		}
	}
	
	/** 
	 * The method put a value with respective key, in values HashMap.
	 * @param key The key of the value.
	 * @param value The respective value.
	 */
	public void putValue(String key, Object value){
		if(!this.keys.contains(key)){
			this.keys.add(key);
		}
		this.values.put(key,value);
	}
    
    /** 
     * The method put a cont with respective key, in values HashMap.
     * @param key The key of the value.
     * @param value The respective cont.
     */
    public void putCont(String key, Object value){
        this.contMap.put(key,value);
    }
	
	/**
	 * The method return a value relative to the passed key
	 * @param key The key of the value that will be the return. 
	 * @return The respective value of the Key.
	 */
	public Object getValue(String key){
		return this.values.get(key);
	}
    
    /**
     * The method return a cont relative to the passed key
     * @param key The key of the cont that will be the return. 
     * @return The respective value of the Key.
     */
    public Object getCont(String key){
        return this.contMap.get(key);
    }
	
	/**
	 * The method return the label.
	 * @return Returns The label.
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * The method set the field label from the parameter label.
	 * @param label The label to set.
	 */
	public void setLabel(String label) {
		this.label = label;
	}

	/**
	 * The method return the values.
	 * @return Returns The values.
	 */
	public HashMap<String, Object> getValues() {
		return values;
	}

	/**
	 * The method set the field values from the parameter values.
	 * @param values The values to set.
	 */
	public void setValues(HashMap<String, Object> values) {
		this.values = values;
	}

	/**
	 * The method return the x.
	 * @return Returns The x.
	 */
	public double getX() {
		return x;
	}

	/**
	 * The method set the field x from the parameter x.
	 * @param x The x to set.
	 */
	public void setX(double x) {
		this.coord.x = x;
		this.x = x;
	}

	/**
	 * The method return the y.
	 * @return Returns The y.
	 */
	public double getY() {
		return y;
	}

	/**
	 * The method set the field y from the parameter y.
	 * @param y The y to set.
	 */
	public void setY(double y) {
		this.coord.y = y;
		this.y = y;
	}

	/**
	 * The method return the z.
	 * @return Returns The z.
	 */
	public double getZ() {
		return z;
	}

	/**
	 * The method set the field z from the parameter z.
	 * @param z The z to set.
	 */
	public void setZ(double z) {
		this.coord.z = z;
		this.z = z;
	}

	/**
	 * The method return the coord.
	 * @return Returns The coord.
	 */
	public IPoint3d getCoord() {
		return coord;
	}

	/**
	 * The method set the field coord from the parameter coord.
	 * @param coord The coord to set.
	 */
	public void setCoord(IPoint3d coord) {
		this.x = coord.x;
		this.y = coord.y;
		this.z = coord.z;
		this.coord = coord;
	}

	
	/**
	 * The method set the field keys from the parameter keys.
	 * @param keys The keys to set.
	 */
	public ArrayList<String> getKeys() {
		return this.keys;
	}
	
	/**
	 * The method set the field keys from the parameter keys.
	 * @param keys The keys to set.
	 */
	public void setKeys(ArrayList<String> keys) {
		this.keys = keys;
	}

    public HashMap<String, Object> getContMap() {
        return contMap;
    }

    public void setContMap(HashMap<String, Object> contMap) {
        this.contMap = contMap;
    }

}// end of this class
